﻿Imports Newtonsoft.Json

Public Class LoginManager

    Private manager As SQLManager

    Public Sub New()
        manager = New SQLManager
    End Sub


    Public Function login(ByVal username As String, ByVal pas As String) As Employee
        Dim empArr As List(Of Employee)
        Dim emp As New Employee
        Dim query As String = "SELECT * FROM `tbl_employee` WHERE `tbl_employee`.`username` = '" + username + "' AND `tbl_employee`.`password` = '" + pas + "'"
        Dim resultString As String = "" + manager.executeQuery(query)

        empArr = JsonConvert.DeserializeObject(Of List(Of Employee))(resultString)

        If (resultString = "") OrElse empArr.Count <= 0 Then
            Return Nothing
        End If

        For Each tempEmp As Employee In empArr
            emp = tempEmp
            Return emp
            Exit For
        Next


        Return Nothing
    End Function





End Class
